/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Damian
 */
@Entity
@Table(name = "offer_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OfferType.findAll", query = "SELECT o FROM OfferType o"),
    @NamedQuery(name = "OfferType.findByIdOfferType", query = "SELECT o FROM OfferType o WHERE o.idOfferType = :idOfferType"),
    @NamedQuery(name = "OfferType.findByName", query = "SELECT o FROM OfferType o WHERE o.name = :name")})
public class OfferType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_OFFER_TYPE")
    private Integer idOfferType;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "name")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idType")
    private Collection<Offer> offerCollection;

    public OfferType() {
    }

    public OfferType(Integer idOfferType) {
        this.idOfferType = idOfferType;
    }

    public OfferType(Integer idOfferType, String name) {
        this.idOfferType = idOfferType;
        this.name = name;
    }

    public Integer getIdOfferType() {
        return idOfferType;
    }

    public void setIdOfferType(Integer idOfferType) {
        this.idOfferType = idOfferType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public Collection<Offer> getOfferCollection() {
        return offerCollection;
    }

    public void setOfferCollection(Collection<Offer> offerCollection) {
        this.offerCollection = offerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOfferType != null ? idOfferType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OfferType)) {
            return false;
        }
        OfferType other = (OfferType) object;
        if ((this.idOfferType == null && other.idOfferType != null) || (this.idOfferType != null && !this.idOfferType.equals(other.idOfferType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.OfferType[ idOfferType=" + idOfferType + " ]";
    }
    
}
